home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!cs.odu.edu!Amiga-Request
- From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
- Newsgroups: comp.sources.amiga
- Subject: v90i195: ls 4.0k - yet another unix-like ls command, Part01/04
- Message-ID: <13039@xanth.cs.odu.edu>
- Date: 3 Jul 90 19:22:41 GMT
- Sender: tadguy@cs.odu.edu
- Reply-To: kim@uts.amdahl.com (Kim E. DeVaughn)
- Lines: 1534
- Approved: tadguy@cs.odu.edu (Tad Guy)
- X-Mail-Submissions-To: Amiga@cs.odu.edu
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: kim@uts.amdahl.com (Kim E. DeVaughn)
- Posting-number: Volume 90, Issue 195
- Archive-name: unix/ls-4.0k/part01
-
- [ uuencoded executable and object enclosed. ...tad ]
- [ the file ls.c was split for posting. ...tad ]
-
- I've reworked Justin McCormick's "ls" (v3.1) so it's output and
- option flags (where applicable) are much closer to UNIX's implementation, by
- default. It still isn't a "perfect" emulation, but it's quite close.
-
- Along the way, I've fixed a number of bugs (none terribly major), added some
- additional features, and just about run out of letters for the option flags!
-
- If Justin thought "ls" was getting bloated with options in his most recent
- rev (v3.1), he'll surely gag after seeing what I've done :-). Still, with
- all the new options, etc, "ls" is only about 16K. And it can still be made
- resident, etc. In fact, with the right set of switches, you can make it
- behave just like v3.1 (bug fixes excepted) if you want!
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 4)."
- # Contents: License README README.1ST ls.doc src src/Linkfile
- # src/Makefile src/ls.h src/mycres.a src/mycres.o.uu
- # Wrapped by tadguy@xanth on Tue Jul 3 15:22:09 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'License' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'License'\"
- else
- echo shar: Extracting \"'License'\" \(2444 characters\)
- sed "s/^X//" >'License' <<'END_OF_FILE'
- XLicense 05/11/90
- X
- Xls v4.0k is (c) Copyright 1990, Kim E. DeVaughn, all rights reserved.
- X
- XAny possesor of this version (v4.0k) of "ls" for the Amiga is hereby granted
- Xa non-exclusive license permitting its use and/or redistribution, subject to
- Xthe following terms and conditions.
- X
- XPermission is hereby granted to freely redistribute this version of "ls" via
- Xelectronic bulletin board systems (BBS's), freely redistributable disk
- Xcollections (such as provided by Fred Fish), service bureaus (BiX, GEnie,
- XCompuServe, etc), and networks such as USENET, BITNET, and Internet, provided
- Xthat such distribution includes this unmodified License, and all of the
- Xdocumentation files (README and .doc files), in addition to the executable,
- Xand with all copyright notices intact. Access to the source code must also
- Xbe available and allowed.
- X
- XUse of the "ls" executable and docmentation in any environment, commercial or
- Xotherwise is not restricted, and no fee shall be required for said use. The
- Xuse of the source code is also permitted in other freely redistributable works,
- Xprovided proper acknowledgement of the authors is given. The use of the source
- Xcode in a commercial product is prohibited without prior written permission
- Xof the author.
- X
- XWithout prior written permission from the author, it is prohibited to sell or
- Xotherwise convey this version of "ls" for monetary or other forms of compen-
- Xsation, other than the customery service and/or duplication fees as may be
- Xcharged by the distribution mechanisms identified above.
- X
- XIt is further prohibited, without prior written permission from the author,
- Xto include this version of "ls" in whole or in part, in the distribution of
- Xany commercial hardware or software package, or component thereof.
- X
- XThis version of "ls" is provided "as is", without express or implied warranty.
- XThe author makes no claim or representation about the suitability of this
- Xsoftware for any purpose.
- X
- XThe author disclaims any and all warranties with regard to this software,
- Xincluding all implied warranties of merchantability and fitness. In no event
- Xshall the author be liable for any special, indirect, or consequential
- Xdamages, or any damages whatsoever resulting from loss of use, data, or
- Xprofits, whether in an action of contract, negligence, or other tortious
- Xaction, arising out of or in connection with the use or performance of this
- Xsoftware.
- X
- XKim E. DeVaughn
- X750 Sylvan Av, #32
- XMt. View, CA 94041
- END_OF_FILE
- if test 2444 -ne `wc -c <'License'`; then
- echo shar: \"'License'\" unpacked with wrong size!
- fi
- # end of 'License'
- fi
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(15901 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XREADME ls v4.0k 05/11/90
- X
- Xls v4.0k is (c) Copyright 1990, Kim E. DeVaughn, all rights reserved.
- X
- X
- XIntroduction:
- X
- XWhat?! Another version of "ls" ...? Why in the world does the world need
- XYet Another Version of such a common command? Actually, that's the answer
- X(as well as the question).
- X
- XIf you kept track of such things (like some operating systems do), you'd
- Xprobably find the "most executed" command is by far, "ls" (or dir, etc).
- X
- XWe use "ls" not only to see what's where, but when what's there got there,
- Xhow big it is, what it's attributes are, etc. We also use "ls" to check our
- Xspelling, make lists of files, and so forth.
- X
- XBecause of this high usage, we'd like it to work the way we think it ought
- Xto, or at least the way we're used to. For alot of people, this means
- X"like UNIX(R)".* Not that the UNIX way is the *best* way, but when you have
- Xto deal with UNIX at work, etc, it makes it much more convenient and prod-
- Xuctive (not to mention much less error prone), to have the Amiga environment
- X"similar". At least in the CLI/shell environment.
- X
- X * - UNIX is a registered trademark of AT&T, if you didn't know.
- X
- XTo that end, I've reworked Justin McCormick's "ls" (v3.1) so it's output and
- Xoption flags (where applicable) are much closer to UNIX's implementation, by
- Xdefault. It still isn't a "perfect" emulation, but it's quite close.
- X
- XAlong the way, I've fixed a number of bugs (none terribly major), added some
- Xadditional features, and just about run out of letters for the option flags!
- X
- XIf Justin thought "ls" was getting bloated with options in his most recent
- Xrev (v3.1), he'll surely gag after seeing what I've done :-). Still, with
- Xall the new options, etc, "ls" is only about 16K. And it can still be made
- Xresident, etc. In fact, with the right set of switches, you can make it
- Xbehave just like v3.1 (bug fixes excepted) if you want!
- X
- XThe reason for this is that I'm a very firm believer in letting people "have
- Xit their way". I'm sure I could chop out about 4K or more if I just did it
- X"my way", but other people have other ideas. The default way however, *is*
- X"my way" ... or actually "the UNIX way".
- X
- X [ BTW ... if you want this version of "ls" to look/work like v3.1, the ]
- X [ following switches will do it for you: -AMSWbemoqv ... :-) ]
- X
- X
- X
- XInstallation:
- X
- XJust copy "ls" to a directory in your path. If the "p" (pure) bit has been
- Xstripped of somewhere along the way, you can turn it on using the Protect
- Xcommand (or chmod, etc) if you want to make "ls" a "resident" command.
- X
- X
- X
- XDistribution:
- X
- XHere is a listing of what you should have received in this distribution:
- X
- X-----rw-d 7 2444 May 10 18:23 License
- X-----rw-d 33 15901 Jun 5 11:31 README
- X-----rw-d 4 1204 Jun 5 11:09 README.1ST
- X---p-rwxd 34 16028 May 11 02:13 ls
- X-----rw-d 43 20124 May 11 09:46 ls.doc
- Xd----rwxd 1 0 Jun 5 10:35 src
- XDirs: 1 Files: 5 Blocks: 122 Bytes: 54949
- X
- Xsrc:
- X-----rw-d 2 457 May 10 19:07 Linkfile
- X-----rw-d 3 590 May 10 18:52 Makefile
- X-----rw-d 137 65576 May 11 02:02 ls.c
- X-----rw-d 9 3685 May 10 18:53 ls.h
- X-----rw-d 73 34948 May 10 18:51 lssup.a
- X-----rw-d 12 5160 Jul 29 1989 mycres.a
- X-----rw-d 4 1104 Jul 29 1989 mycres.o
- XDirs: 0 Files: 7 Blocks: 240 Bytes: 111520
- X
- XTotals:
- XDirs: 1 Files: 12 Blocks: 362 Bytes: 166469
- X
- X
- X
- XWhat's New (see "ls.doc" for details, etc):
- X
- X o New (default) long listing format that *looks* like UNIX's (except for
- X things like owner, group ID, etc).
- X
- X o Block sizes now include *all* blocks associated with a file, and are
- X finally accurate for FFS devices.
- X
- X o By default, upper/lower case *is* significant in the output listing,
- X and in the wildcard pattern matching.
- X
- X o By default, directories and files are intermixed, according to their
- X alphabetic position.
- X
- X o By default, the short listing format uses fixed width columns, based
- X on the length of the longest filename in the directory. Variable
- X width columns are still available.
- X
- X o By default, "hidden", "*.info", and "dot" files (eg, .foo) are not
- X displayed. There are switches for each, as well as an "all" flag.
- X
- X o Several new options like the ability to limit the "-R" recursion depth;
- X ability to show absolute and relative path names in the long format
- X listing; additional control of directory header and totalization
- X lines; elimination of redundent totalization lines; showing/sorting
- X on files' "disk keys"; control of the date format; sort by date/size
- X defaults to newest/biggest first; and a few other things.
- X
- X o Improved error handling and error msgs. Better "break" handling. No
- X more "memory leaks" (yes, there is one in v3.1 ... it looses 300 bytes
- X on an error exit).
- X
- X o The assignment of option flags has been "rationalized". Applicable
- X flags from the UNIX "ls" were assigned 1st, followed by other flags
- X from v3.1, followed by new flags added in this rev. However ... some
- X flag assignments from previous revs were changed when better mnemonic
- X values could be found, etc. So ... check the usage, and/or docs.
- X Caveat emptor!
- X
- X o Flags requiring arguments (eg, -N) may or may not be seperated from
- X the argument by spaces. So, "-Nfoo" is just as legal as "-N foo".
- X
- X
- X
- XWhat's Not (yet) Done ... and Limitations/Caveats:
- X
- X o Wildcard expansion is still done by "ls", rather than left to the shell
- X to do so (which is where it should be done, IMHO). This is to avoid
- X the braindead limitation of being able to pass a command line of only
- X 255 chars or so max to Exec() under AmigaOS 1.3. Hopefully this limit
- X will be removed under AmigaOS 2.0.
- X
- X This also means that if the shell you're using expands normal wildcards
- X ("*" and "?") itself, you need to "quote" the wildcards in some manner
- X for "ls" to work as intended. Depending on the shell you use, things
- X like "*" or \* or '* may work. See your shell documentation.
- X
- X o Each "fully named path" is still processed seperately, and will give
- X you an automatic "long format list" for each file encountered, or a
- X "short format list" for each subdirectory encountered. This is why
- X you will get some rather weird output listings if you let your shell
- X expand wildcards, rather than passing the wildcards intact to "ls".
- X (A "fully named path" is a filespec that contains no wildcards ... in
- X other words, an actual file or dir name).
- X
- X This will change. How it wiil change is somewhat dependent on what is
- X done in AmigaOS 2.0 with command line length limits, links, etc.
- X
- X o Many flag settings get reset to the default values between each "fully
- X named path". Some do not, and are identified in "ls.doc" as being
- X "sticky".
- X
- X This will change when the "fully named path" and wildcard expansion
- X issues are resolved.
- X
- X o Doesn't support AmigaOS v2.0 links (or any other 2.0 enhancements),
- X since CBM hasn't finalized it (besides, I don't have 2.0 yet).
- X
- X o I want to allow the user to override the default operation with flags
- X provided in environment variables. This will require reworking "ls's"
- X startup code (or the use of the standard "cres", with accompanying
- X bloat of the executable) due to the current env var implementation as
- X files. Dumb.
- X
- X o The filename arguments required for the -N and -O options must be fully
- X specified. Wildcards don't work here.
- X
- X o The -N and -O options accept only filenames; they do not accept actual
- X dates.
- X
- X o You must hit "return" to clear the short format's builtin pager's
- X "More ..." line (see -I), and continue with the listing. I'd like to
- X change this to being able to hit any key.
- X
- X Also, the builtin pager works only on a directory-by-directory basis.
- X It'd be nice (read: this probably won't happen) if it worked on the
- X output as a whole. And if it worked with the long format listing.
- X
- X o When a long format listing is requested of a "psuedo-device", the
- X block count may be inaccurate, since such "devices" do not necessarily
- X have an inherent (or constant) bytes/block value. Currently, the only
- X such case known are assignments made with the "pathass" utility. When
- X this situation occurs, a warning message is issued to the effect that
- X the block counts may be inaccurate.
- X
- X
- X
- XKnown Bugs:
- X
- X o Multiple wildcards in a given path do not work properly. For example,
- X the command: "ls ls*/*.o" lists the entire contents of the "ls40"
- X subdirectory, not just the ".o" files.
- X
- X o Certain options are slightly incompatible. The known instances occur
- X with the old (v3.1) long format, and the variable column form of the
- X short format, as I didn't touch that code much. Known instances are:
- X
- X Show keys (-K) does not work with the old (-o) long format.
- X
- X Append "/" to dir names (-p) does not work with the variable
- X column short format (-vp will NOT append a "/"). However, if no
- X ANSI escape sequences (-E) is specified along with -v, they will
- X be appended to dir names. This is the same behavior as "ls" v3.1.
- X
- X o Seperate subdir totalization for "fully named path" entries does not
- X work. However, their contribution to a grand total (-T) is included.
- X
- X
- X
- XQuick Look:
- X
- Xusage: ls [ [-options <args>] [names] ] ...
- X a Show dot files s Sort by size M Ignore case w/wildcard
- X b Show data blks t Sort by date N <name> Show newer than
- X c Show filenotes u Usage [also -?] O <name> Show older than
- X d Show dirs only v Vari col short list P Show full pathnames
- X e Execute bit is "e" x <pat> Exclude files Q Requesters enabled
- X f Show files only z Override blk calc R Recursive listing
- X h Show hidden files A Show all [= -ahi] S Show dirs first
- X i Show *.info files B <blk> Force blk size T Totals for all entries
- X k Sort by disk key C Single column list V Show rel pathnames
- X l Long listing D Show dirs last W No contents (wild dir)
- X m Mixed case output E No ANSI escape codes X <wide> Set output cols
- X n No sort G No subdir totals Y <high> Set output rows
- X o Old long list fmt H No headings Z Force ANSI sequences
- X p Append "/" to dirs I No page prompts 0-6 Date format (new long)
- X q Quit on not found K Show disk keys - Next arg is filename
- X r Reverse sort L <n> Limited recursion
- X F <format> Format output [-o fmt] (default: "%p %d %t %4b %8s %n\n")
- X
- X
- X
- XTech Notes:
- X
- X o This version of "ls" was compiled/assembled using Lattice v5.05, with
- X optimization on. See the Makefile and Linkfile for details. Also
- X note that to use the source level debugger "cpr", you need to use one
- X of the commented out CFLAG strings in the Makefile with -d3, as well
- X as uncommenting the ADDSYM statement in the Linkfile.
- X
- X o The file "mycres.o" is included, as I couldn't get "mycres.a" to
- X assemble ... no includes called "exec/funcdef.i" anywhere I could find,
- X etc. I didn't have a real reason to muck with that code, so I didn't
- X pursue the matter. The "mycres.o" file is from the v3.1 distribution,
- X and works fine (except when you try using getenv() ...).
- X
- X o My enhancements to "ls" have evolved bit-by-bit over a period of about
- X a year. Consequently, the code is somewhat less than "pristine". I'm
- X sure it can be cleaned up a bit, though I tried to keep my changes from
- X getting too ugly. Also, I've tried to more or less stay with Justin's
- X coding style, but I know that hasn't been completely successful either.
- X Anyway, you've been warned; if you go reading the code, send flames
- X to /dev/null ... :-)
- X
- X
- X
- XRevision History:
- X
- X Kim E. DeVaughn
- X
- X v4.0k May 11, 1990 Pretty much completely revised the output formats.
- X Much more like UNIX's "ls" in its output, options,
- X etc. Several bugs fixed. Many new options.
- X
- X Justin V. McCormick
- X
- X v3.1 July 29, 1989 Bug fixes, new output width and height options.
- X v3.0 July 25, 1989 Instant sorting, best-fit output, new features.
- X v2.2 December 1988 Fixed status return and multiple wildcard pathnames.
- X v2.1 December 1988 Minor size reduction, fixed a few bugs from 2.0.
- X v2.0 November 1988 Revised for Lattice 5.0 and made 1.3 compatible.
- X v1.0 August 1986 Written from scratch, my first Amiga project.
- X
- X
- X
- XAcknowledgements, Etc:
- X
- XFirst, let me thank Justin McCormick for providing "ls" v3.1, and the very
- Xgood algorithms from which I was able to build upon. His inline sorting in
- Xparticular made his version the one I chose to enhance because of it's speed.
- X
- XA very excellent job, and my sincere thanks go to him for a job well done!
- X
- XSecond, let me thank Tom Rokicki for the "date" algorithm I used, and to
- XRob Peck for publishing it in his excellent book, "Programmer's Guide to the
- XAmiga" (Sybex). Both of these people have contributed much to the Amiga
- Xdevelopment community!
- X
- XThird, I want to thank Matt Dillon for providing his fine DME editor, and
- Xmany, *many* examples of how to program the Amiga. If you ever need to know
- Xhow to do something, take a look a Matt's code ... chances are he's done it,
- Xand in a lean, mean, fast way!
- X
- X
- XFinally, I want to mention that this version of "ls" is copyrighted, whereas
- XJustin's previous versions were explicitly "public domain". Specifically, I
- Xam copyrighting this version of the executable "ls", the "ls.c" and "ls.h"
- Xsource files, and the "ls.doc" and "README" files.
- X
- XThis is completely legal, since the base version I used had been declared to
- Xbe in the "public domain". I feel totally justified in doing so due to the
- Xextensive changes that I've made.
- X
- XYou'll note, if you read the "License", that I'm not trying to restrict the
- Xuse or redistribution of this version of "ls", other than to insure that it
- Xisn't used by anyone to make money out of, myself included. In particular,
- Xcertain "diskzines" seem to be unscrupulously "raiding" the freely redistrib-
- Xutable software base lately, in an attempt to help sell their disk/magazines.
- X
- XMost of the ones I've seen are *trash*, and the prices they charge are a bit
- Xoutrageous, considering what they provide. I do not wish to help them. Not
- Xeven in a slight way.
- X
- XAnyway, I hope nobody has a big problem with this. If you do, lemee hear
- Xfrom you.
- X
- X
- X
- XThe Future:
- X
- XThere will definitely be at least one more release of my version of "ls". It
- Xwill address those items mentioned in the "What's Not Done" and "Known Bugs"
- Xsections above. In particular, it will support AmigaOS 2.0's enhancements,
- Xsuch as links. Given 2.0's probable availability, I doubt this will happen
- Xmuch before the end of 1990. We shall see.
- X
- XIn the meantime, let me hear from you if there are things you like (or don't).
- XAnd especially if you find any bugs, "features", or anomalies. And if (God
- Xforbid), there's a useful option I've managed to overlook, don't hesitate to
- Xput in a request ... there are still a few option flags left ... :-)
- X
- XIn addition to my electronic addresses (see signature below), I can be
- Xreached at:
- X
- X Kim E. DeVaughn
- X 750 Sylvan Av, #32
- X Mt. View, CA 94041
- X
- XHowever, email to my USENET/UUCP address is probably the surest way to get
- Xin touch with me, and should be used if at all possible.
- X
- X
- X/kim /\oo/\
- X
- X--
- XUUCP: kim@uts.amdahl.com
- X or: {sun,decwrl,hplabs,pyramid,uunet,oliveb,ames}!amdahl!kim
- XDDD: 408-746-8462
- XUSPS: Amdahl Corp. M/S 249, 1250 E. Arques Av, Sunnyvale, CA 94086
- XBIX: kdevaughn GEnie: K.DEVAUGHN CIS: 76535,25
- END_OF_FILE
- if test 15901 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'README.1ST' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README.1ST'\"
- else
- echo shar: Extracting \"'README.1ST'\" \(1204 characters\)
- sed "s/^X//" >'README.1ST' <<'END_OF_FILE'
- XIn case the "p" (pure) bit got stripped off in the archiving/dearchiving
- Xprocess ... yes, ls v4.0k is "residentable". Just use the Protect command
- X(or chmod, etc) to turn it back on, and you can "resident" it.
- X
- XSee the README for known limitations, bugs, etc. One WARNING upfront ... if
- Xthe shell you're using expands normal wildcards (* and ?) itself, you'll need
- Xto use the shell's quoting mechanism for "ls" to work as intended. If you
- Xlet the shell expand wildcards for you, the output can be somewhat "strange".
- XSee the README for why this is the way it is (for now).
- X
- XA quick plea to shell writers ... *please* provide a mechanism for semi-
- Xautomatically disabling wildcard expansion is your shells! One easy way to
- Xdo this is to not expand the wildcards until an actual command (not an
- Xalias) that will use the filelist is to be executed. Then one could define
- Xan alias something like: "alias xls 'set nowild;ls;unset nowild'", and have
- Xthe expansion controlled on a command-by-command basis. Even better if you
- Xcan issue commands as part of the "prompting" function, as "unset nowild"
- Xwould work better there (in case the user ^C'd out of the command proper).
- X
- XEnjoy ...!
- X
- X/kim 06/05/90
- END_OF_FILE
- if test 1204 -ne `wc -c <'README.1ST'`; then
- echo shar: \"'README.1ST'\" unpacked with wrong size!
- fi
- # end of 'README.1ST'
- fi
- if test -f 'ls.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ls.doc'\"
- else
- echo shar: Extracting \"'ls.doc'\" \(20124 characters\)
- sed "s/^X//" >'ls.doc' <<'END_OF_FILE'
- X
- X LS(1) AmigaOS 1.3 LS(1)
- X
- X
- X NAME
- X ls - list contents of directory
- X
- X
- X SYNOPSIS
- X ls [ [ -options <args> ] [ names ] ] ...
- X
- X
- X DESCRIPTION
- X For each directory name argument, ls lists the contents of the
- X directory; for each file name argument (non-wildcarded), ls
- X lists the entry using the long listing format. If wildcards
- X (* or ?) are passed to ls, it internally expands the filespec
- X into a list of names, and lists them in the requested format
- X (short, long, or single column).
- X
- X The output is sorted alphabetically, by default, and the short
- X format listing is used unless the argument name is a "fully named
- X path" (i.e., one without wildcards), or an option flag requests a
- X different format.
- X
- X When no argument is given, the current directory is listed. When
- X several arguments are given, the arguments are processeed in the
- X order presented, with "non-sticky" option flags being reset to the
- X default value between arguments. Option flags may preceed the
- X individual name arguments.
- X
- X There are three major listing formats. The default format is to
- X list the entries in a short, columnar format, with entries sorted
- X down the columns. The long and single column (one entry per line)
- X formats are enabled with various options.
- X
- X For the short format, ls reads the size of the current window to
- X determine the character positions available on one line, and the
- X number of lines available without scrolling. If this information
- X cannot be obtained, ls assumes 77 columns by 23 lines. A builtin
- X "pager" is available by default when the short format is used.
- X
- X The output formats and applicable option switches are designed to
- X emulate the UNIX(R) equivalent as closely as possible.
- X
- X The options are as follows:
- X
- X -a Lists entries including those whose names begin with a
- X dot (.) These are not listed by default.
- X
- X -b Normally, the long format listing shows the total number
- X of blocks used by an entry (including the File Header
- X and Extension blocks). This option limits the block
- X count to the number of Data Blocks only.
- X
- X -c Shows the comment/filenote for an entry, if any. The
- X comment is shown enclosed in quote marks on a line
- X beneath the entry. This option implies the long format
- X listing.
- X
- X -d Show only entries that are directories.
- X
- X -e By default, ls shows the "execute" attribute bit in the
- X long format listing as an "x". This option changes that
- X to an "e". [sticky]
- X
- X -f Show only entries that are files (i.e., not directories).
- X
- X -h Lists entries including those whose "hidden" attribute
- X bit is set. These are not listed by default.
- X
- X -i Lists entries including those whose names end with the
- X string ".info". These are not listed by default.
- X
- X -k The output listing is sorted by the disk "key" value of
- X the entries. [sticky]
- X
- X -l Lists in long format, giving the entrys' attribute bits,
- X comment present flag, disk key (if -k or -K specified),
- X size in blocks, size in bytes, date, and name.
- X
- X -m Lists entries with the case "mixed". Normally, the case
- X of entry names is respected when sorting.
- X
- X -n No sorting of entries is performed. Entries are listed
- X the order in which they are Examined by the system.
- X
- X -o Use the old ls version (v3.1) long format when a long
- X listing is requested. Note: this option does not cause
- X a long listing by itself, but only specifies that the
- X old format be used, should a long listing be requested
- X (see notes below).
- X
- X -p Puts a slash (/) after each entry name if that entry is
- X a directory.
- X
- X -q Normally, ls will continue to process name arguments
- X until the argument list is exhausted. This option will
- X cause ls to terminate when an entry is not found. (This
- X option only has meaning for "fully named path" args).
- X
- X -r Reverses the sort order to get reverse alphabetic, oldest,
- X smallest, or highest key first as appropriate.
- X
- X -s Sort by size, with largest first. [sticky]
- X
- X -t Sort by date, with newest first. [sticky]
- X
- X -u Display a short usage summary, showing syntax and options.
- X
- X -v Use variable column widths in the short format listing.
- X Normally, ls bases the column widths on the longest name
- X in the directory, and uses that value for all columns.
- X This option allows each column's width to be determined
- X by the longest name in the column itself.
- X
- X -x pat
- X Excludes entries matching the pattern "pat" from the
- X listing. The pattern string may contain "*" and "?",
- X which are interpreted as wildcards with the usual meaning.
- X [sticky]
- X
- X -z Overrides the calculation of the block counts, and shows
- X the value found in the filesystem's NumBlocks entry.
- X This option is useful for getting an indication of a
- X file's current block size if the file is being written to,
- X or if the file resides on a psuedo-device (such as a
- X "pathass" assign) that has no inherent bytes/block value.
- X Note: the block count reported should only be used as an
- X indicator, as it may not be exact.
- X
- X -A Lists all entries. This option is equivalent to using
- X the a, h, and i options together. Note: entries matching
- X the exclude pattern (-x) are not listed.
- X
- X -B size
- X Normally, ls computes an entry's block count using the
- X bytes/block value appropriate for the filesystem or
- X device on which the entries reside (currently 512 for the
- X FFS, and 488 for the OFS). This option allows that value
- X to be specified directly, which can be useful to determine
- X if an entry or entries will "fit" on a device which has a
- X different bytes/block value. In such usage, the "size"
- X of the target device would be specified by the option's
- X argument, and the block count obtained then compared to
- X the number of blocks available on the target device (with
- X Info, for example). [sticky]
- X
- X -C Single column (one entry per line) output format. Note:
- X this usage of "-C" is exactly opposite UNIX's usage.
- X
- X -D Normally, files and directories are intermixed in the
- X output listings. With this option, all directories will
- X appear seperately, and last in the listing.
- X
- X -E Normally, ANSI escape codes are used to highlight names
- X of directory entries and comments. This option disables
- X such highlighting. Note: ANSI escape codes are normally
- X automatically disabled when the ls output is redirected
- X to stdout or is piped. [sticky]
- X
- X -F <format>
- X Allows the specification of the output format when the
- X old long format is used. This option implies -l and -o
- X (see notes below).
- X
- X -G Disables the subdirectory-by-subdirectory summary totals
- X normally provided when the long format listing is used.
- X
- X -H Disables printing of the subdirectory name header line
- X normally provided for other than the current directory.
- X
- X -I Normally, when using the short format, if the number of
- X entries is larger than can be displayed in the window ls
- X is using, a builtin "pager" is invoked to prevent the
- X list from scrolling. This option (as well as output re-
- X direction or pipeing) inhibits the pager.
- X
- X -K Display disk "keys" in the long format listing. Normally,
- X they are not shown. This option implies the long format.
- X
- X -Ln Recursively lists subdirectories encountered, with depth
- X limited to "n" levels. A depth of n = 1 lists only the
- X current directory.
- X
- X -M Ignore alphabetic case when matching directory contents
- X with wildcard patterns. Normally, the case of names is
- X respected. This option applies to both name arguments,
- X and exclude (-x) patterns.
- X
- X -N name
- X Show only entries that are newer than entry "name".
- X "Name" cannot be wildcarded.
- X
- X -O name
- X Show only entries that are older than entry "name".
- X "Name" cannot be wildcarded.
- X
- X -P Show entry names as full (absolute) path names. This
- X option implies the long format.
- X
- X -Q Normally, ls disables the system requesters that pop up
- X when a device is empty, etc, and presents an error msg.
- X This option turns them on again. [sticky]
- X
- X -R Recursively lists subdirectories encountered.
- X
- X -S Normally, files and directories are intermixed in the
- X output listings. With this option, all directories will
- X appear seperately, and first in the listing.
- X
- X -T Provides a grand total of all files and directories, and
- X their sizes, for all entries processed. This option is
- X valid with all formats. Note: the seperate totalization
- X line will not be printed, if the information is simply a
- X duplication (as it would be for just a long format list
- X of the current directory).
- X
- X -V Show entry names as relative (to the current directory)
- X path names. This option implies the long format.
- X
- X -W Normally, when a "wildcarded match" occurs on a directory
- X entry, its contents are listed. This option prevents the
- X contents from being listed. Only the directory name will
- X be printed.
- X
- X -X width
- X Forces the short format to use "width" for the number of
- X columns available in ls's window. [sticky]
- X
- X -Y height
- X Forces the short format to use "height" for the number of
- X lines available in ls's window. [sticky]
- X
- X -Z Forces output of ANSI escape sequences for highlighting,
- X even though the ls output may be redirected to stdout, or
- X piped. See also, -E. [sticky]
- X
- X -0 thru
- X -6 Specifies the format to be used for the date in the long
- X listing (not applicable to the -o long format). [sticky]
- X
- X Available formats are:
- X 0: age to years: mmm d hh:mm aging to mmm dd yyyy
- X 1: full: mmm dd yyyy hh:mm:ss
- X 2: dash alpha: dd-mmm-yy hh:mm:ss
- X 3: dash numeric: mm-dd-yy hh:mm:ss
- X 4: slash: mm/dd/yy hh:mm:ss
- X 5: european: dd/mm/yy hh:mm:ss
- X 6: dot: yy.mm.dd hh:mm:ss
- X
- X Format 0 is the default, and is the format used by UNIX.
- X The "aging" period is 180 days, and the day may be either
- X one or two digits, as required.
- X
- X -? Synonym for "-u". Displays a short usage summary.
- X
- X - Forces the next argument to be interpreted as a name.
- X This is useful for specifying entries whose names begin
- X with the "-" character.
- X
- X
- X The attribute bits printed in the default long format consist of a
- X nine character string. Each position contains a letter if the
- X attribute it represents is "true", or a "-" otherwise. If all
- X attributes were to apply to a single entry, the string would appear
- X as "dhsparwxd", where:
- X
- X d indicates the entry is a directory
- X h indicates the entry is a hidden entry
- X s indicates the entry is a script file
- X p indicates the entry is a pure executable (residentable)
- X a indicates the entry has been archived, and not modified since
- X r indicates the entry is readable
- X w indicates the entry is writable
- X x indicates the entry is executable (or "e" with the -e option)
- X d indicates the entry is deletable
- X
- X It should be noted that AmigaOS 1.3 includes only marginal support
- X of the attribute bits, and enforces few of them. The above however
- X is their formal definition. Also, "directory" is not an attribute
- X bit, but is included in the attribute string. Further, a "c" flag
- X will appear to the right of the attribute string should an entry
- X have an associated comment/filenote (or a blank if not).
- X
- X AmigaOS makes provisions for additional attributes, some of which
- X may be application specific. Should any of these be set, ls will
- X display a "+" instead of a "-" in the hidden attribute position,
- X or an "H" if the hidden attribute itself also applies.
- X
- X
- X The ls -l (default long list) command prints its output as follows:
- X
- X --sa-rw-d c 136 65383 May 5 18:15 fubar
- X
- X This horizontal configuration provides a good deal of information.
- X From right to left, you see that the current directory holds one
- X file, named "fubar". It was created (or at least last modified) at
- X 6:15 P.M. on May 5th. It contains 65,383 bytes, and occupies 136
- X blocks on the device where it is located (including the file header
- X block, and any extension blocks). There is a comment associated
- X with the file, and it is (supposedly) a script file that has been
- X archived, and may be read, written, and deleted.
- X
- X
- X EXAMPLES
- X ls -a
- X
- X This command prints the names of all files in the current directory,
- X including those that begin with a dot (.), which normally are not
- X printed. The short format is used.
- X
- X
- X ls -cAKP1
- X
- X This command provides you with a maximum amount of information on
- X all files in the current directory, including those that normally
- X do not print (A), associated comments, if any (c), the disk key
- X numbers (K), the full path name (P), and the full date format (1).
- X A long format listing is implied (both c and P).
- X
- X
- X ls -ARTB488
- X
- X This command prints the names of all files in the current directory
- X (A), and all subdirectories below it (R), with a grand total of the
- X counts and sizes at the end (T). Block counts are computed as if
- X the files were located on an OFS (Old File System) device (B488),
- X and the short format is used.
- X
- X If the files were actually located on an FFS (Fast File System)
- X device, such as a hard disk partition, comparing the grand total of
- X the block counts to the available blocks on an OFS floppy (with say,
- X Info) would tell you if the tree would fit on the floppy.
- X
- X
- X ls -hrtX50 -Y 15 -Tx*zoo
- X
- X This command prints a short format listing of the current directory,
- X including hidden files (h), sorted by date (t), with oldest files
- X first (r). The output "window" is restricted to 50 columns (X50),
- X by 15 lines (Y 15). A totalization of all entries is requested (T),
- X and entries ending with the string "zoo" will be excluded (x*zoo).
- X
- X
- X ls -lN df0:emily.c -sOdf1:lynn.c df0:*.c
- X
- X This command prints a long format listing (l) of all files ending
- X with the string ".c" on df0: that are newer than "df0:emily.c"
- X (N df0:emily.c), but are older than "df1:lynn.c" (Odf1:lynn.c).
- X The listing will be sorted by size, with largest files first (s).
- X
- X
- X NOTES
- X Wildcards:
- X ----------
- X Normal wildcards may be used in file names and in the last level of
- X a directory path name. The "*" character is used to match any
- X number of characters (including zero), and a "?" matches any single
- X character. Wildcards may also be used in specifying an exclusion
- X pattern (-x).
- X
- X If the shell that is used to invoke ls expands the wildcards itself,
- X they MUST be quoted in some manner for ls to work as intended.
- X Some common shell quoting methods are: "*" or \* or '* See your
- X shell documentation for details.
- X
- X
- X Options:
- X --------
- X Option flags may be given in any order. Where options conflict,
- X such as specifying both -s and -t, the last option encountered is
- X the one used.
- X
- X Option flags may be given grouped or seperately. E.g., "-lsR" is
- X logically the same as "-l -s -R".
- X
- X Options requiring an argument, such as -x or -B, must be the last
- X option in a group, or given seperately, and must be immediately
- X followed by the argument (with or without seperating blanks). The
- X forms: "-ltB488", "-ltB 488", "-lt -B488", and "-l -B 488 -t"
- X are all correct, and logically the same. The form "-lB488t" is
- X NOT correct, and will result in unspecified behavior.
- X
- X Options are normally reset to their default state between name
- X arguments. Some flags however, apply to all name arguments, and
- X are identified as "sticky" in the option descriptions above.
- X
- X
- X Pathnames:
- X ----------
- X A pathname with spaces in it like "Wombat Soup", must be surrounded
- X by quotes. Up to 30 seperate pathname patterns can be processed by
- X ls per command.
- X
- X
- X Aborting:
- X ---------
- X ls may be aborted at any time by issuing a control-C (assuming the
- X invoking shell passes ^C's along to the applications). ls will
- X print the string "**BREAK" and then terminate when this occurs.
- X
- X
- X Formatted Output:
- X -----------------
- X For customized output, there is a special option that expects a
- X format rule as the next argument:
- X
- X -F <format>
- X Format output with <format), using the following symbols:
- X %p print the attribute bits
- X %d print the date: yy-mm-dd
- X %t print the time: hh-mm-ss
- X %b print the number of blocks used by the entry
- X %s print the number of bytes used by the entry
- X %n print the name of the entry
- X %% print a percent symbol
- X \n print a linefeed
- X \t print a tab
- X \\ print a backslash symbol
- X
- X The default format rule that ls uses for old format long
- X listings is: -F "%p %d %t %4b %8s %n\n". Note that a format
- X specification that contains spaces must be quoted.
- X
- X Any of the format options that begin with the '%' symbol can
- X have an optional pad count that lets you specify how many
- X columns to use. For example: -F "%40n\n" would print each
- X entry name right justified in a field of 40 columns.
- X
- X The attribute bits in this format are as described above, with
- X one exception: the first position is used to indicate that the
- X entry has an associated comment. If so, a "c" is used (else a
- X "-").
- X
- X You can use this feature of ls to help create simple batch
- X command files. For example, the command:
- X
- X ls -PF "copy %n RAM:\n" df0:*.h
- X
- X tells ls to perform a listing using full pathnames with a
- X special format, matching only filenames that end with ".h" in
- X directory df0:. Suppose df0: has the following files in it:
- X
- X joe.h fred.h pete.h ted.h
- X
- X The example ls command would result in the following list of
- X commands:
- X
- X copy df0:fred.h RAM:
- X copy df0:joe.h RAM:
- X copy df0:pete.h RAM:
- X copy df0:ted.h RAM:
- X
- X A script file from this by redirecting the output of ls to a
- X temporary file:
- X
- X ls >ram:templist -PF "copy %n RAM:\n" df0:*.h
- X execute ram:templist ; do the script,
- X delete ram:templist ; and delete it
- X
- X
- X Tip:
- X ----
- X To list files older or newer than a certain date, rather than a
- X certain file, you can do this:
- X
- X echo >RAM:datemark "Marker" ; create a temp file in RAM:
- X setdate RAM:datemark 07-Jul-89 ; set datestamp for temp file
- X ls -N ram:datemark df0: ; list files newer than "datemark"
- X delete ram:datemark ; remove temp file
- X
- X
- X CAVEATS/BUGS
- X Refer to the README file accompanying this distribution for notes
- X of any currently known bugs or limitations.
- X
- X
- X AUTHORS
- X Justin V. McCormick is the author of the of ls (v3.1), and other
- X earlier revisions. Version 3.1 was used as a base on which to
- X develop the current revision (v4.0k), because of its excellent
- X "inline" sorting and its columnation algorithms, as well as its
- X small size, and fast code.
- X
- X Kim E. DeVaughn provided the numerous enhancements, fixes, etc, to
- X bring v3.1 up to the current v4.0k.
- X
- X
- X COPYRIGHT
- X ls v4.0k is (c) Copyright 1990, Kim E. DeVaughn, all rights
- X reserved. See the "License" accompanying this distribution for
- X limitations, and other details.
- X
- X UNIX is a registered trademark of AT&T. They had nothing to do
- X with any of this code, but did provide the "model" for some of its
- X output formats and options.
- END_OF_FILE
- if test 20124 -ne `wc -c <'ls.doc'`; then
- echo shar: \"'ls.doc'\" unpacked with wrong size!
- fi
- # end of 'ls.doc'
- fi
- if test ! -d 'src' ; then
- echo shar: Creating directory \"'src'\"
- mkdir 'src'
- fi
- if test -f 'src/Linkfile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/Linkfile'\"
- else
- echo shar: Extracting \"'src/Linkfile'\" \(457 characters\)
- sed "s/^X//" >'src/Linkfile' <<'END_OF_FILE'
- X;Link with file for LS by Justin V. McCormick 89-07-25
- X;Stubs out lots of unused things that Lattice 5.0 dragged in
- XDEFINE @write=@nullstub
- XDEFINE @_dwrite=@nullstub
- XDEFINE @_dseek=@nullstub
- XDEFINE @_dclose=@nullstub
- XDEFINE @CXBRK=@nullstub
- XFROM
- X;lat:lib/cres.o
- Xmycres.o
- Xls.o
- Xlssup.o
- XTO ls-new
- XLIB lib:lcr.lib lib:amiga.lib
- XSC SD
- XND
- X;Uncomment ADDSYM below for debugging with "cpr"
- X;ADDSYM
- X;VERBOSE
- X;MAP link.map F H L S X PLAIN WIDTH 84 HEIGHT 0 SWIDTH 20
- END_OF_FILE
- if test 457 -ne `wc -c <'src/Linkfile'`; then
- echo shar: \"'src/Linkfile'\" unpacked with wrong size!
- fi
- # end of 'src/Linkfile'
- fi
- if test -f 'src/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/Makefile'\"
- else
- echo shar: Extracting \"'src/Makefile'\" \(590 characters\)
- sed "s/^X//" >'src/Makefile' <<'END_OF_FILE'
- X# -------------------------------------------------
- X# ls 2.3 Makefile by Justin V. McCormick 89-07-05
- X# Modified for v4.0k by Kim E. DeVaughn - 05/11/90
- X# -------------------------------------------------
- X#CFLAGS = -cfmtu -d1 -m0 -rr -v
- X#CFLAGS = -cfmtu -d3 -m0 -rr -v
- X#CFLAGS = -cfmtu -d3 -m0 -rr -v -O
- XCFLAGS = -cfmtu -d1 -m0 -rr -v -O
- XAFLAGS = -u
- X
- XOBJS = mycres.o ls.o lssup.o
- X
- X# rename "ls-new" to "ls" before installation (this avoids conflicts when testing a new version)
- XDEST = ls-new
- X
- X$(DEST): $(OBJS)
- X blink with Linkfile
- X
- Xlssup.o: lssup.a
- X asm $(AFLAGS) lssup.a
- X
- Xls.c: ls.h
- END_OF_FILE
- if test 590 -ne `wc -c <'src/Makefile'`; then
- echo shar: \"'src/Makefile'\" unpacked with wrong size!
- fi
- # end of 'src/Makefile'
- fi
- if test -f 'src/ls.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/ls.h'\"
- else
- echo shar: Extracting \"'src/ls.h'\" \(3685 characters\)
- sed "s/^X//" >'src/ls.h' <<'END_OF_FILE'
- X/*
- X * ls.h - header file for a UNIX-like directory utility
- X *
- X * ls v4.0k is (c) Copyright 1990, Kim E. DeVaughn, all rights reserved.
- X *
- X */
- X
- X/* Prevent Lint from complaining about ANSI prototype extensions */
- X#ifdef _lint
- X
- X#define __asm
- X#define __stdargs
- X#define __regargs
- X#define R_D0
- X#define R_D1
- X#define R_A0
- X
- X#else
- X
- X#define R_D0 register __d0
- X#define R_D1 register __d1
- X#define R_A0 register __a0
- X
- X#endif
- X
- X/* Use Real strlen unless you comment out the following */
- X#define strlen strlen
- X
- X#include <dos.h>
- X#include <libraries/dosextens.h>
- X
- X/*lint -save */
- X/*lint -library */
- X#include <stdio.h>
- X#include <string.h>
- X#include <stdlib.h>
- X#include <signal.h>
- X#include <proto/exec.h>
- X#include <proto/dos.h>
- X/*lint -restore */
- X
- Xextern int tolower (char);
- X
- X#define MEMF_PUBLIC (1L << 0)
- X#define MEMF_CHIP (1L << 1)
- X#define MEMF_FAST (1L << 2)
- X#define MEMF_CLEAR (1L << 16)
- X
- X#define SUPPRESS_ERR_REQ (void *)-1L
- X
- X/* usage defines ... error codes eventually reported to the OS as DOS #120's */
- X#define SYNTAX 0L
- X#define ILLEGAL_ARG 120000L
- X#define MISSING_ARG 120010L
- X#define PATTERN_ERR 120020L
- X#define WILDSPEC_ERR 120030L
- X
- X/* Structure used to hold file info in a linked list */
- Xstruct FibEntry
- X{
- X struct MinNode fe_Node;
- X struct FileInfoBlock *fe_Fib;
- X};
- X
- Xtypedef struct FileInfoBlock FIB;
- Xtypedef struct FileLock FLK;
- Xtypedef struct InfoData ID;
- X
- X#define MAX_BLKS_PER_EXTENT 72
- X
- X/* Maximum number of command line args, buffer sizes, etc. */
- X#define MAXARG 32
- X#define MAXDEPTH 0x7fffffff
- X#define MAXFNLEN 30
- X#define PADTABSIZE 100
- X#define WORKSIZE 300
- X
- X/* Flag bits for LSFlags and LSFlagsX */
- X#define BREAKFLAG (1L << 0)
- X#define CONSOLE (1L << 1)
- X#define SHOWDIRS (1L << 2)
- X#define SHOWFILES (1L << 3)
- X#define LISTALL (1L << 4)
- X#define LONGLIST (1L << 5)
- X#define NOSORTFLAG (1L << 6)
- X#define NOTEFLAG (1L << 7)
- X#define PATHNAMED (1L << 8)
- X#define REVFLAG (1L << 9)
- X#define WILDPATH (1L << 10)
- X#define FULLPATHNAMES (1L << 11)
- X#define ANTIMATCH (1L << 12)
- X#define TOTALIZE (1L << 13)
- X#define NOHEADERS (1L << 14)
- X#define NOINTERACT (1L << 15)
- X#define FILESFIRST (1L << 16)
- X#define SEPFILESDIRS (1L << 17)
- X#define SHOWOLDERTHAN (1L << 18)
- X#define SHOWNEWERTHAN (1L << 19)
- X#define IGNORECASELIST (1L << 20)
- X#define IGNORECASEWILD (1L << 21)
- X#define MATCHDOTFILES (1L << 22)
- X#define MATCHINFOFILES (1L << 23)
- X#define SHOWHIDDEN (1L << 24)
- X#define OLDLONGFORMAT (1L << 25)
- X#define VARCOLSFORMAT (1L << 26)
- X#define ONECOLFORMAT (1L << 27)
- X#define ADDDIRSLASH (1L << 28)
- X#define SHOWDISKKEYS (1L << 29)
- X#define RELPATHNAMES (1L << 30)
- X#define NODIRTOTAL (1L << 31)
- X#define WILDPATHFLAG (1L << 32 - 32)
- X#define SINGLEFILEFLAG (1L << 33 - 32)
- X#define DATABLKSONLY (1L << 34 - 32)
- X#define NOWILDPATHDIRS (1L << 35 - 32)
- X#define EMPTYDIRFLAG (1L << 36 - 32)
- X#define NOTFOUNDHALT (1L << 37 - 32)
- X#define NOFIXNUMBLOCKS (1L << 38 - 32)
- X
- X
- X/* defines for datestr() */
- X
- X#define TIME_YEAR_THRESHOLD 180 /* days for AGE_TO_YEARS format */
- X /* change -----v d = space or D */
- X#define AGE_TO_YEARS 0 /* MMM dD HH:MM or MMM dD YYYY */
- X#define FULL_FORM 1 /* MMM DD YYYY HH:MM:SS */
- X#define DASHA_FORM 2 /* DD-MMM-YY HH:MM:SS */
- X#define DASHN_FORM 3 /* MM-DD-YY HH:MM:SS */
- X#define SLASH_FORM 4 /* MM/DD/YY HH:MM:SS */
- X#define EURO_FORM 5 /* DD/MM/YY HH:MM:SS */
- X#define DOT_FORM 6 /* YY.MM.DD HH:MM:SS */
- X
- X
- X/* defines for attrstr() */
- X
- X#define FIBB_HIDDEN 7 /* not in 1.3 includes, but works with Protect */
- X#define FIBF_HIDDEN (1 << FIBB_HIDDEN)
- X
- X#define FIBF_RESERVED ~(FIBF_HIDDEN | FIBF_SCRIPT | FIBF_PURE | \
- X FIBF_ARCHIVE | FIBF_READ | FIBF_WRITE | \
- X FIBF_EXECUTE | FIBF_DELETE)
- END_OF_FILE
- if test 3685 -ne `wc -c <'src/ls.h'`; then
- echo shar: \"'src/ls.h'\" unpacked with wrong size!
- fi
- # end of 'src/ls.h'
- fi
- if test -f 'src/mycres.a' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/mycres.a'\"
- else
- echo shar: Extracting \"'src/mycres.a'\" \(5160 characters\)
- sed "s/^X//" >'src/mycres.a' <<'END_OF_FILE'
- X* mycres.a - Specialized C initial startup procedure under AmigaDOS
- X* Adapted for LS use from c.a by Justin V. McCormick 89-05-12
- X* Converted to CAPE 89-06-03
- X*
- X IFD CAPE ; Special OP flags for CAPE
- X
- X CSYMFMT
- X BASEREG B
- X SMALLOBJ
- X OPTIMON
- X ADDSYM
- X include "work:ipre.i" ; A precompiled collection of the below...
- X
- X ELSE
- X
- X INCLUDE "exec/types.i"
- X INCLUDE "exec/alerts.i"
- X INCLUDE "exec/nodes.i"
- X INCLUDE "exec/lists.i"
- X INCLUDE "exec/ports.i"
- X INCLUDE "exec/libraries.i"
- X INCLUDE "exec/tasks.i"
- X INCLUDE "exec/memory.i"
- X INCLUDE "exec/execbase.i"
- X INCLUDE "libraries/dos.i"
- X INCLUDE "libraries/dosextens.i"
- X INCLUDE "workbench/startup.i"
- X INCLUDE "exec/funcdef.i"
- X INCLUDE "exec/exec_lib.i"
- X INCLUDE "libraries/dos_lib.i"
- X
- X ENDC
- X
- X
- XMEMFLAGS EQU MEMF_CLEAR+MEMF_PUBLIC
- X
- X; some usefull macros:
- X
- XSYS MACRO *
- X IFGT NARG-2
- X FAIL !!!
- X ENDC
- X IFEQ NARG-2
- X MOVE.L \2,a6
- X ENDC
- X JSR _LVO\1(a6)
- X ENDM
- X
- X XDEF XCEXIT ; exit(code) is standard way to leave C.
- X XDEF @XCEXIT
- X
- X XREF @myalloc
- X XREF @myfree
- X XREF @astrncpy ; String copy routine
- X XREF DOSBase
- X XREF LinkerDB ; linker defined base value
- X XREF NEWDATAL
- X XREF RESBASE
- X XREF RESLEN
- X XREF _BSSBAS ; linker defined base of BSS
- X XREF _BSSLEN ; linker defined length of BSS
- X XREF @_main ; Name of C program to start with.
- X; XREF @MemCleanup ; Free all allocated memory
- X
- X SECTION CODE
- X* --------------------------------------------------------------------- *
- Xstart:
- X move.l a0,a2 ; save command pointer
- X move.l d0,d2 ; and command length
- X lea LinkerDB,a4 ; load base register
- X
- X movem.l d0-d1/a0-a2,-(sp)
- X sub.l #RESBASE,a4
- X move.l #RESLEN,d0
- X move.l #MEMFLAGS,d1
- X SYS AllocMem,4
- X tst.l d0
- X bne 1$
- X movem.l (sp)+,d0-d1/a0-a2
- X rts
- X
- X1$
- X move.l d0,a0
- X move.l d0,a2
- X
- X; a2 now has difference
- X move.l d0,a1
- X move.l #NEWDATAL,d0
- X; copy data over
- Xcpy:
- X move.l (a4)+,(a0)+
- X subq.l #1,d0
- X bne cpy
- X; a4 now points at number of relocs
- X move.l (a4)+,d0
- Xreloc:
- X beq.s nreloc
- X move.l a1,a0
- X add.l (a4)+,a0 ; a0 now has add of reloc
- X add.l (a0),a2
- X move.l a2,(a0)
- X move.l a1,a2 ; restore offset
- X subq.l #1,d0
- X bra reloc
- X
- Xnreloc:
- X move.l a1,A4 ; set up new base register
- X add.l #RESBASE,A4
- X movem.l (sp)+,d0-d1/a0-a2
- X
- X movea.l 4,a6
- X move.l a6,SysBase(A4)
- X move.l sp,_StackPtr(A4) ; Save stack ptr
- X
- X; get the address of our task
- X move.l ThisTask(a6),a3
- X
- X; clear any pending signals
- X moveq #0,d0
- X move.l #$00003000,d1
- X SYS SetSignal
- X
- X; are we running as a son of Workbench?
- X tst.l pr_CLI(a3)
- X bne.s fromCLI
- X
- X* --------------------------------------------------------------------- *
- X* Workbench Startup Code
- XfromWorkbench:
- X; wait for a message from our starter
- X lea pr_MsgPort(a3),a0 ; our process base
- X SYS WaitPort
- X lea pr_MsgPort(a3),a0 ; our process base
- X SYS GetMsg
- X move.l d0,d2
- X beq.w exitToDOS
- X
- X; return the startup message to our parent
- X; we forbid so workbench can't UnLoadSeg() us
- X; before we are done:
- X SYS Forbid
- X movea.l d2,a1
- X SYS ReplyMsg
- X bra.w exitToDOS
- X
- X* --------------------------------------------------------------------- *
- X* CLI Startup Code
- X; Entry: d2 = command length
- X; a2 = Command pointer
- XfromCLI:
- X; attempt to open DOS library:
- X lea DOSName(PC),a1
- X moveq #0,d0
- X SYS OpenLibrary
- X move.l d0,DOSBase(A4)
- X bne.s 1$
- X moveq #100,d0
- X bra.s exit2
- X1$
- X; find command name:
- X move.l pr_CLI(a3),a3
- X add.l a3,a3 ; bcpl pointer conversion
- X add.l a3,a3
- X move.l cli_CommandName(a3),a3
- X add.l a3,a3 ; bcpl pointer conversion
- X add.l a3,a3
- X
- X; collect parameters:
- X move.l d2,d0 ; get command line length
- X moveq.l #0,d1
- X move.b (a3)+,d1
- X add.l d1,d0 ; add length of command name
- X addq.l #1,d0 ; allow for space after command
- X jsr @myalloc ; allocate enough space for whole cmd line
- X tst.l d0
- X beq.s closeDOS ; Oops, allocate failed
- X move.l d0,_CmdLine(A4)
- X
- X; copy command name into allocated space
- X movea.l a3,a1
- X movea.l d0,a0
- X moveq #0,d0
- X move.b -1(a3),d0
- X jsr @astrncpy
- X
- X; insert a space unless command itself is the only argument
- X cmpi.w #2,d2
- X bcs.s 2$
- X move.b #' ',(a0)+
- X
- X; Append/copy command line into allocated space
- X move.l d2,d0
- X movea.l a2,a1
- X jsr @astrncpy
- X2$
- X movea.l _CmdLine(A4),a0 ; push command line address
- X
- X* --------------------------------------------------------------------- *
- X* Call @_main
- Xmain:
- X jsr @_main ; call C entrypoint
- X moveq.l #0,d0 ; set successful status
- X bra.s exit2
- XXCEXIT:
- X move.l 4(sp),d0 ; extract exit return code
- X@XCEXIT:
- Xexit2:
- X move.l d0,-(sp) ; Save exit return status
- X
- X movea.l _CmdLine(A4),a0
- X jsr @myfree ; Free command line
- X
- X; jsr @MemCleanup ; Free malloced resources
- X
- XcloseDOS:
- X; Close the DOS library
- X move.l DOSBase(A4),a1
- X SYS CloseLibrary,4 ; close Dos library
- X
- X; this rts sends us back to DOS:
- XexitToDOS:
- X move.l #RESLEN,d0
- X movea.l A4,a1
- X suba.l #RESBASE,a1
- X move.l (sp)+,d7 ; Grab exit return code
- X movea.l _StackPtr(A4),sp ; restore stack ptr
- X SYS FreeMem,4
- X move.l d7,d0 ; Put exit return code in d0
- X rts
- X
- X*-----------------------------------------------------------------------
- XDOSName dc.b 'dos.library',0
- X
- X
- X SECTION _MERGED,BSS
- X* --------------------------------------------------------------------- *
- X XDEF _CmdLine
- X XDEF SysBase
- X XDEF _StackPtr
- X_CmdLine:
- X ds.b 4
- XSysBase:
- X ds.b 4
- X_StackPtr
- X ds.b 4
- X END
- END_OF_FILE
- if test 5160 -ne `wc -c <'src/mycres.a'`; then
- echo shar: \"'src/mycres.a'\" unpacked with wrong size!
- fi
- # end of 'src/mycres.a'
- fi
- if test -f 'src/mycres.o.uu' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/mycres.o.uu'\"
- else
- echo shar: Extracting \"'src/mycres.o.uu'\" \(1583 characters\)
- sed "s/^X//" >'src/mycres.o.uu' <<'END_OF_FILE'
- Xbegin 644 mycres.o
- XM```#YP````````/H`````E]#3T1%```````#Z0```%@D2"0`2?D`````2.?`6
- XMX)G\`````"`\`````"(\``$``2QX``1.KO\Z2H!F```(3-\'`TYU($`D0")`D
- XM(#P`````(-Q3@&;Z(!QG#B!)T=S5T""*)$E3@P*$G9_`````!,WP<#+'@`0
- XM!"E.```I3P``)FX!%'``(CP``#``3J[^SDJK`*QF)$'K`%Q.KOZ`0>L`7$ZN3
- XM_HPD`&<``)I.KO]\(D).KOZ&8```C$/Z`*AP`$ZN_=@I0```9@1P9&!>)FL`2
- XMK-?+U\LF:P`0U\O7RR`"<@`2&]"!4H!.N0````!*@&=&*4```")+($!P`!`K8
- XM__].N0`````,0@`"90X0_``@(`(B2DZY`````"!L``!.N0````!P`&`$("\`_
- XM!"\`(&P``$ZY`````")L```L>``$3J[^8B`\`````"),D_P`````+A\N;```8
- XM+'@`!$ZN_RX@!TYU9&]S+FQI8G)A<GD````#[X$```)?4D530D%310````,``
- XM```0````7````3Z!```"0&UY9G)E90`````!```!)($```-`87-T<FYC<'D`4
- XM```````"````\@```0:!```"0%]M86EN```````!```!$($```)?4D533$5._
- XM``````(````6```!-H$```-?3&EN:V5R1$(````````!````!H$```-?3D57Q
- XM1$%404P````````!````/($```)`;7EA;&QO8P````$```#:A@```E]$3U-"!
- XM87-E`````@```+8```$JA@```E]3>7-"87-E`````0```&J&```#7U]3=&%CZ
- XM:U!T<@```````@```&X```%&A@```U]?0VUD3&EN90````````,```#D```!C
- XM#````2`!```"0%A#15A)5`````$<`0```E]80T58250````!&`````````/PE
- XM`````E]$3U-.86UE```!5`````)?9G)O;4-,20```*H````"7W-T87)T````#
- XM`````````D!80T58250````!'`````)?;6%I;@```````0X````"7VYR96QO*
- XM8P````!8`````U]E>&ET5&]$3U,``````30````"7V5X:70R``````$<````?
- XM`E]80T58250````!&`````1?9G)O;5=O<FMB96YC:```````A@````-?8VQOO
- XM<V5$3U,```````$H`````5]C<'D```!``````E]R96QO8P``````2```````1
- XM``/R```#Z`````)?7TU%4D=%1````^L````#```#[P$```)?4WES0F%S90``3
- XM``0!```#7U]3=&%C:U!T<@``````"`$```-?7T-M9$QI;F4`````````````8
- XM`````_`````"7U-Y<T)A<V4````$`````U]?4W1A8VM0='(```````@````#*
- X87U]#;61,:6YE``````````````````/R/
- X``
- Xend
- Xsize 1104
- END_OF_FILE
- if test 1583 -ne `wc -c <'src/mycres.o.uu'`; then
- echo shar: \"'src/mycres.o.uu'\" unpacked with wrong size!
- fi
- # end of 'src/mycres.o.uu'
- fi
- echo shar: End of archive 1 \(of 4\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
- Mail comments to the moderator at <amiga-request@cs.odu.edu>.
- Post requests for sources, and general discussion to comp.sys.amiga.
-